/**
 * Created by Quaye on 2016/12/21.
 */
var debug = new QyDebug();


function QyDebug() {
    var m_qyDebug = this;
    m_qyDebug.needLog = true;
    m_qyDebug.out = (function (logMsg) {
        if (m_qyDebug.needLog == true)
            console.log("[--[Debug]--]:" + logMsg)
    });
    m_qyDebug.outWarning = (function (warMsg) {
        if (m_qyDebug.needLog == true)
            console.log("[-[Warning]-]:" + "%c" + warMsg, "color:#FFA500")
    });
    m_qyDebug.outError = (function (errMsg) {
        if (m_qyDebug.needLog == true)
            console.log("[--[Error]--]:" + "%c" + errMsg, "color:#DB7093")
    });
}

function ReadTxtFileFunc(txtFiles) {

    var m_GFC = this;
    m_GFC.EndReadFilesEvent = null;
    m_GFC.StartReadName = m_GetFileJson;
    var m_selectedFile = txtFiles[0];
    var m_reader = new FileReader();

    function m_GetFileJson() {
        debug.out("- read in -");
        m_reader.onload = OnLoadText;
        m_reader.readAsText(m_selectedFile);
        debug.out("- read out -")
    }

    function OnLoadText() {
        if (m_GFC.EndReadFilesEvent != null)
            m_GFC.EndReadFilesEvent(this.result);
        else
            debug.outWarning("what happen !! event is null.")
    };

}

